package io.cw.service.impl.iml.background;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.cw.common.utils.StringUtils;
import io.cw.dao.background.RelRoomSeatDao;
import io.cw.entity.background.RelRoomSeatEntity;
import io.cw.entity.background.RelRoomTimeEntity;
import io.cw.service.impl.background.RelRoomSeatService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * 教室座位 服务类
 *
 * @author cw
 */
@Service
public class RelRoomSeatServiceImpl extends ServiceImpl<RelRoomSeatDao, RelRoomSeatEntity> implements RelRoomSeatService {


    @Override
    @Transactional
    public void batchInsert(List<RelRoomSeatEntity> entityList) {
        this.saveBatch(entityList);
    }

    @Override
    public String getSeatNo(int num, Integer digit) {
        return StringUtils.fillZeroChar(num+1, digit);
    }

    @Override
    public void deleteByRoomId(String roomId) {
        QueryWrapper<RelRoomSeatEntity> deleteWrapper = new QueryWrapper();
        deleteWrapper.lambda().eq(RelRoomSeatEntity::getRoomId, roomId);
        this.remove(deleteWrapper);
    }
}
